{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "33063b3c-3ac8-4ad1-ad3c-6d0844783550",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object): \n",
    "    @property\n",
    "    def score(self):\n",
    "        return self._score\n",
    "\n",
    "    @score.setter\n",
    "    def score(self, value): \n",
    "        if not isinstance(value, int): \n",
    "            raise ValueError('score must be an integer!')\n",
    "        if value < 0 or value > 100:\n",
    "            raise ValueError('score must between 0 ~ 100!')\n",
    "        self._score =value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9aecd448-8bf6-4dee-84dd-14226879a930",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Student() \n",
    "s.score = 60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a99d3d5b-fc9f-435f-bb24-757b20e250d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "caa845e1-8b92-41b2-b53c-9577353d103e",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "score must between 0 ~ 100!",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[5], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43ms\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscore\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m999\u001b[39m\n",
      "Cell \u001b[1;32mIn[2], line 11\u001b[0m, in \u001b[0;36mStudent.score\u001b[1;34m(self, value)\u001b[0m\n\u001b[0;32m      9\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mscore must be an integer!\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m     10\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m value \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0\u001b[39m \u001b[38;5;129;01mor\u001b[39;00m value \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m100\u001b[39m:\n\u001b[1;32m---> 11\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mscore must between 0 ~ 100!\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m     12\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_score \u001b[38;5;241m=\u001b[39mvalue\n",
      "\u001b[1;31mValueError\u001b[0m: score must between 0 ~ 100!"
     ]
    }
   ],
   "source": [
    "s.score = 999"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4a311c67-5872-42dd-9be3-366339951c82",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object): \n",
    "    @property\n",
    "    def score(self):\n",
    "        return self._score\n",
    "\n",
    "    @score.setter\n",
    "    def score(self, value): \n",
    "        if not isinstance(value, int): \n",
    "            raise ValueError('score must be an integer!')\n",
    "        if value < 0 or value > 100:\n",
    "            raise ValueError('score must between 0 ~ 100!')\n",
    "        self._score =value\n",
    "    \n",
    "    @property\n",
    "    def birth(self): \n",
    "        return self._birth\n",
    "\n",
    "    @birth.setter\n",
    "    def birth(self,value):\n",
    "        self._birth = value\n",
    "\n",
    "    @property\n",
    "    def age(self): \n",
    "        return 2015- self._birth"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1875a735-ec6a-4c81-b9c2-508a830c36a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Screen(object):\n",
    "\n",
    "    @property\n",
    "    def getwidth(self):\n",
    "        return self._wdith\n",
    "\n",
    "    @getwidth.setter\n",
    "    def setterwidth(self, value):\n",
    "        self._wdith = value\n",
    "scr = Screen()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "42f1ae02-03b2-4db7-a067-9ee9f336a92c",
   "metadata": {},
   "outputs": [],
   "source": [
    "scr.width  = 30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "068e00b6-b376-4dc7-b5be-f8130a6f09de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scr.width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "3ee45ffb-fd45-4e5d-83c4-59812706d505",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scr.width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eeb6eb17-529e-48af-82d6-cb7c5fcb333a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
